#include "ddsport.h"

#include <QElapsedTimer>
#include "public/publicfunction.h"
#include <QThread>
#include <QElapsedTimer>

DdsPort::DdsPort()
{
    //init only required for windows, no-op on *nix
    //net::init();
}


DdsPort::~DdsPort()
{
    //net::uninit();
}


/**
 * @brief NetPort::open
 * @param type
 * @param args
 * @return true-成功, false-失败
 */
bool DdsPort::open(QString type, QStringList args)
{
    if(type == "" || args.length() != 2)
        return false;

    ip = args.at(0);
    port = args.at(1).toInt();

    return reOpen();
}

/**
 * @brief NetPort::reOpen
 * @return true-成功, false-失败
 */
bool DdsPort::reOpen()
{


    return 0;
}

int DdsPort::read(unsigned char *buf, int len, int ms)
{
    qDebug() << "DdsPort::read";
    QElapsedTimer timer;
    timer.start();

    QByteArray byteArray;

#if 0
    qDebug()<< "read: " << hexToString(byteArray.data(), len);
#endif

    return len;
}

int DdsPort::write(unsigned char *buf, int len, int ms)
{
#if 0
    qDebug()<< "write: " << hexToString((char *)buf, len);
#endif
    return 0;
}


bool DdsPort::close()
{
    return true;
}

TPortType DdsPort::getPortType()
{
    return PORT_DDS;
}

